package com.example.othree.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.othree.entity.PollutionHistoryDataJjjSitesDay;
import com.example.othree.entity.WeatherHistoryData;
import com.example.othree.mapper.PollutionHistoryDataJjjSitesDayMapper;
import com.example.othree.service.PollutionHistoryDataJjjSitesDayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class PollutionHistoryDataJjjSitesDayServiceImpl extends ServiceImpl<PollutionHistoryDataJjjSitesDayMapper, PollutionHistoryDataJjjSitesDay> implements PollutionHistoryDataJjjSitesDayService {

    @Resource
    PollutionHistoryDataJjjSitesDayMapper pollutionHistoryDataJjjSitesDayMapper;

    @Override
    public List<HashMap<String, String>> pollutionAnalyzeDataByCityForAvg(String startTime, String endTime, String element, String[] cities) {
        return pollutionHistoryDataJjjSitesDayMapper.pollutionForSiteByAvea(startTime, endTime, element, cities);
    }

    @Override
    public List<HashMap<String, String>> pollutionAnalyzeDataByCityForEvery(String startTime, String endTime, String element, String[] cities) {
        return pollutionHistoryDataJjjSitesDayMapper.pollutionForSiteByEvery(startTime, endTime, element, cities);
    }

    @Override
    public IPage pollutionPageList(IPage<HashMap<String, String>> page, String[] cities, String[] elements, String startTime, String endTime) {
//        IPage r =  pollutionHistoryDataJjjSitesDayMapper.pollutionPageList(page, cities, elements, startTime, endTime);
//        List<HashMap<String, String>> result = page.getRecords();
//        for (HashMap<String, String> i : result){
//            if (i.get("pm25").isEmpty()){
//
//            }else {
//                String data = i.get("pm25");
//                i.remove("pm25");
//                i.put("pm2.5", data);
//            }
//        }

        return pollutionHistoryDataJjjSitesDayMapper.pollutionPageList(page, cities, elements, startTime, endTime);
    }

    @Override
    public List<HashMap<String, String>> pollutionAnalyzeDataByTime(String startTime, String endTime, String[] stations) {
        return pollutionHistoryDataJjjSitesDayMapper.pollutionAnalyzeDataByTime(startTime, endTime, stations);
    }
}
